Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

248
Visualizações
Appium [ Javascript ] [WD] - Scroll to an element which is not visible but enabled or clickable

I am using appium javascript client with uiautomator2 as the automation engine for android. In one of screen having multiple buttons like Button 1, Button 2, Button 3 ...etc stacked horizantal with scroll. However, only first two buttons will be visible on page load [ Refer Screen shot].

I want to click on button 4. Have implemented below code to handle scroll and click button but I am unable to break loop since attribute is always false.

            var element = await driver.elementByXPath("//android.widget.Button[contains(@text,'Button 4')]");
            var scrollFromElement = await driver.elementByXPath("//android.widget.Button[contains(@text,'Button 2')]");

            var isEleFocused = await element.getAttribute("focused");
            console.log("concierge element is Focused - " + isEleFocused);

            if (isEleFocused == "false")
            {
                var i = 0;
                do{
                    await swipeElementAndroid(scrollFromElement, "RIGHT")
                    var d1 = await element.getAttribute("focused");
                    if(d1 == "true"){
                        i=10
                        break;
                    }
                    else{
                        await swipeElementAndroid(scrollFromElement, "RIGHT")
                        i=i+1
                        console.log("i="+i)
                    }   
                }while(i<5)
            }       
            
            await sleepwait(500)
            console.log("after scroll- if condition")

            e1 = await driver.elementByXPath("//android.widget.Button[contains(@text,'Button 4')]")
            await e1.click()

Kindly suggest alternative way to handle the same.

Note: Attributes like displayed, clickable are always true even though button is not visible.

enter image description here

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda